package yogiro.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import yogiro.to.MemberTO;
import yogiro.to.PictureTO;
import yogiro.to.TourInfoTO;
import yogiro.to.ZipcodeTO;

public class MemberDAO {
private  SqlMapClientTemplate sqlMap;
	
	public MemberDAO(SqlMapClientTemplate sqlMap){
		this.sqlMap = sqlMap;
	}
	
	public MemberTO  selectMemberById(String id){
		return (MemberTO)sqlMap.queryForObject("selectMemberById", id);
	}
	public  ArrayList<MemberTO> selectMemberList(){
		return(ArrayList<MemberTO>)sqlMap.queryForList("selectMemberList");
	}
	public void updateMemberInfo(MemberTO mto){
		 sqlMap.update("updateMemberInfo",mto);
	}
	public void delete(String id)throws SQLException{
		 sqlMap.delete("deleteById",id);
	}
	
	public void  insertMember(MemberTO mto) throws SQLException{
		 sqlMap.insert("insertMember",mto);
	}
	public ArrayList<ZipcodeTO> selectZipcodeByDong(String dong){
		return (ArrayList<ZipcodeTO>)sqlMap.queryForList("selectZipcodeByDong",dong);
	}
	
	public ArrayList<TourInfoTO> selectTourRecommend(String tourWriterType) throws SQLException{
		return (ArrayList<TourInfoTO>)sqlMap.queryForList("selectTourRecommend", tourWriterType);
	}
	
	public PictureTO selectTourRecommend2(int pictureGroup) throws SQLException{
		return (PictureTO)sqlMap.queryForObject("selectTourRecommend2", pictureGroup);
	}
	public String selectMemberIdByMemberInfo(String birthday, int detail) throws SQLException{
		System.out.println("dao : "+birthday+"||"+detail);
		HashMap map = new HashMap();
		map.put("birthday", birthday);
		map.put("detail", detail);
		return (String) sqlMap.queryForObject("selectMemberIdByMemberInfo",map);
	}
}












